<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <button class="btn1">点击我存储cookie</button>
    <script>
      /*
        cookie: x
        */
      // js操作cookie
      // 一、存cookie：cookie 有域名限制的，一个域名下存储的只能这个域名
      let btn1 = document.querySelector(".btn1");
      btn1.onclick = function () {
        console.log("点击了");
        document.cookie = `myname=lisi;Max-Age=3600`;
      };
    </script>
  </body>
</html>
